<template>
	<f7-page>
		<f7-navbar title="标签扫描" back-link="Back"></f7-navbar>
		<f7-block>
			<img src="../../static/img/mipmap-hdpi/bg_scan.png" class="sao_img" />
			<p class="text-align-center fontS2">可以扫描房间门派、床卡或老人腕带</p>
			
		</f7-block>
	</f7-page>
</template>
<script>
	import { AndroidControl, JavascriptInterface } from "@/utils/AndroidBridge.js";
	export default {
		created: function() {
			var that = this;
			//监听NFC扫描事件
			new JavascriptInterface().jsNFCReceiver((tag) => {
				// alert(tag);
				// that.detail = tag
				if(tag&&tag!='标签数据为空'){
					that.config.RFID = tag;
					that.ajaxJS(tag);
				}else{
					alert('扫描标签失败')
				}
			});
		},
		data() {
			return {
				page_params:this.$f7route.params,
				config:{
					RFID:'',
					rId:'',
					eId:global.COURSES.careId,
				},
				detail:''
			}
		},
		methods: {
			go: function(path) {
				this.$f7.views.main.router.navigate(path);
			},
			ajaxJS(RFID){
				var that = this;
				that.$post(global.COURSES.path + '/building/search', {"search":RFID})
					.then(message => {
						if(message.code==0){
							let resData = JSON.parse(message.data);
							that.config.rId = resData.roomId;
							that.config.rName = resData.roomName;
							if(resData.tag=='jordan'){//便器
								let path = '/Jordan/'+that.config.RFID+'/'+that.config.rId+'/'+that.config.eId+'/';
								// that.detail = path;
								that.$f7.views.main.router.navigate(path);
							}else if(resData.tag=='room'){//查房
								let path = '/lookRoom/'+that.config.RFID+'/'
								// that.detail = path;
								that.$f7.views.main.router.navigate(path);
							}else if(resData.tag=='oldman'){//老人详情
								that.go('/about/'+resData.oldmanId+'/');
							}else{
								alert('error');
							}
						}
					})
			}
			
		}
	};
</script>